<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> 14  Document</title>
    <script src="./js/vue.js"></script>
    <style>
        .table{
            width: 400px;
            margin: 50px auto;
        }
        .table .tr{
            width: 400px;
        }
        .table .tr input{
            width: 100px;
        }
        .table .tr .item{
            width: 100px;
            height: 40px;
            line-height: 40px;
            float: left;
            background-color: darkblue;
            color: darkorange;
            text-align: center;
        }


    </style>
</head>
<body>
    <div id="app">
        <div class="table">
            <div class="tr">
                <span>用户名</span>
                <input type="text">
                <span>用户名</span>
                <input type="text">

                <button>新增</button>

            </div>
            <div class="tr">
                <div class="item">编号</div>
                <div class="item">用户名</div>
                <div class="item">年龄</div>
                <div class="item">操作</div>
            </div>
            <div class="tr"  v-for="item in list" :key="item.id">
                <div class="item">{{item.id}}</div>
                <div class="item">{{item.username}}</div>
                <div class="item">{{item.userage}}</div>
                <div class="item" @click="del(item.id)">删除</div>
            </div>
        </div>

    </div>

    
</body>

<script>

    new Vue({
        el:"#app",
        data:{
            list:[{id:1,username:"sean",userage:18},{id:2,username:"sean",userage:18},{id:3,username:"sean",userage:18}],

        },
        computed:{
        
        },
        methods:{
            del(id){
                // alert(id)
                this.list = this.list.filter(item => item.id != id)

            },
        
        }
    })
</script>
</html>